
#include "tools/variant.h"

#if defined(__GNUC__) || defined(__MINGW32__) || defined(__MINGW__)
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Weffc++"
//    #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif


namespace tools{
    namespace variant_detail{

//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
        ConstRecursiveIterator::ConstRecursiveIterator()
        {
            mStack.emplace();
        }

        ConstRecursiveIterator::ConstRecursiveIterator(Variant& v, const bool beg)
        {
            ThisIterator i(v, ThisIterator::ePRIMITIVE, beg);
            mStack.emplace(i);
        }
        ConstRecursiveIterator::ConstRecursiveIterator(const Variant& v, const bool beg)
        {
            ThisIterator i(v, ThisIterator::ePRIMITIVE, beg);
            mStack.emplace(i);
        }

        ConstRecursiveIterator& ConstRecursiveIterator::operator=(const Variant& v)
        {
            ThisIterator i(v, ThisIterator::ePRIMITIVE, true);

            decltype(mStack) st;
            st.emplace(i);
            swap(st, mStack);
            return *this;
        }


//---------------------------------------------------------------------------------------------
        RecursiveIterator::RecursiveIterator()
        {
            mStack.emplace();
        }

        RecursiveIterator::RecursiveIterator(Variant& v, const bool beg)
        {
            ThisIterator i(v,ThisIterator::ePRIMITIVE,beg);
            mStack.emplace(i);
        }

        Variant& RecursiveIterator::GetVariant()
        {
            return const_cast<Variant&>(Parent::GetVariant());
        }
        Variant& RecursiveIterator::operator*()
        {
            return const_cast<Variant&>(Parent::GetVariant());
        }
        Variant* RecursiveIterator::operator->()
        {
            return const_cast<Variant*>(&Parent::GetVariant());
        }

        RecursiveIterator& RecursiveIterator::operator=(Variant& v)
        {
            ThisIterator i(v,ThisIterator::ePRIMITIVE, true);

            decltype(mStack) st;
            st.emplace(i);
            swap(st, mStack);
            return *this;
        }

//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------


    }//namespace variant_detail
}//namespace tools

#if defined(__GNUC__) || defined(__MINGW32__) || defined(__MINGW__)
    #pragma GCC diagnostic pop
#endif
